text
stringlengths
81
112k
Adds a Grant that the provider should support. :param grant: An instance of a class that extends :class:`oauth2.grant.GrantHandlerFactory` :type grant: oauth2.grant.GrantHandlerFactory def add_grant(self, grant): """ Adds a Grant that the provider should support. ...
Checks which Grant supports the current request and dispatches to it. :param request: The incoming request. :type request: :class:`oauth2.web.Request` :param environ: Dict containing variables of the environment. :type environ: dict :return: An instance of ``oauth2.web.Response...
Enable the use of unique access tokens on all grant types that support this option. def enable_unique_tokens(self): """ Enable the use of unique access tokens on all grant types that support this option. """ for grant_type in self.grant_types: if hasattr(gran...
Returns the value of the HTTP header identified by `name`. def header(self, name, default=None): """ Returns the value of the HTTP header identified by `name`. """ wsgi_header = "HTTP_{0}".format(name.upper()) try: return self.env_raw[wsgi_header] except Key...
Extracts the credentials of a client from the *application/x-www-form-urlencoded* body of a request. Expects the client_id to be the value of the ``client_id`` parameter and the client_secret to be the value of the ``client_secret`` parameter. :param request: The incoming request :type request: oa...
Extracts the credentials of a client using HTTP Basic Auth. Expects the ``client_id`` to be the username and the ``client_secret`` to be the password part of the Authorization header. :param request: The incoming request :type request: oauth2.web.Request :return: A tuple in the format of (<CLIENT...
Authenticates a client by its identifier. :param request: The incoming request :type request: oauth2.web.Request :return: The identified client :rtype: oauth2.datatype.Client :raises: :class OAuthInvalidNoRedirectError: def by_identifier(self, request): """ Au...
Authenticates a client by its identifier and secret (aka password). :param request: The incoming request :type request: oauth2.web.Request :return: The identified client :rtype: oauth2.datatype.Client :raises OAuthInvalidError: If the client could not be found, is not ...
Returns the time until the token expires. :return: The remaining time until expiration in seconds or 0 if the token has expired. def expires_in(self): """ Returns the time until the token expires. :return: The remaining time until expiration in seconds or 0 if the ...
Executes a query and returns the identifier of the modified row. :param query: The query to be executed as a `str`. :param params: A `tuple` of parameters that will be replaced for placeholders in the query. :return: A `long` identifying the last altered row. def execute...
Returns the first result of the given query. :param query: The query to be executed as a `str`. :param params: A `tuple` of parameters that will be replaced for placeholders in the query. :return: The retrieved row with each field being one element in a `...
Returns all results of the given query. :param query: The query to be executed as a `str`. :param params: A `tuple` of parameters that will be replaced for placeholders in the query. :return: A `list` of `tuple`s with each field being one element in the `...
Retrieves an access token by its refresh token. :param refresh_token: The refresh token of an access token as a `str`. :return: An instance of :class:`oauth2.datatype.AccessToken`. :raises: :class:`oauth2.error.AccessTokenNotFound` if not access token could be retrieved. def...
Retrieve an access token issued to a client and user for a specific grant. :param client_id: The identifier of a client as a `str`. :param grant_type: The type of grant. :param user_id: The identifier of the user the access token has been issued to. :ret...
Creates a new entry for an access token in the database. :param access_token: An instance of :class:`oauth2.datatype.AccessToken`. :return: `True`. def save_token(self, access_token): """ Creates a new entry for an access token in the database. :...
Retrieves an auth code by its code. :param code: The code of an auth code. :return: An instance of :class:`oauth2.datatype.AuthorizationCode`. :raises: :class:`oauth2.error.AuthCodeNotFound` if no auth code could be retrieved. def fetch_by_code(self, code): """ ...
Creates a new entry of an auth code in the database. :param authorization_code: An instance of :class:`oauth2.datatype.AuthorizationCode`. :return: `True` if everything went fine. def save_code(self, authorization_code): """ Creates a new entry of an...
Retrieves a client by its identifier. :param client_id: The identifier of a client. :return: An instance of :class:`oauth2.datatype.Client`. :raises: :class:`oauth2.error.ClientError` if no client could be retrieved. def fetch_by_client_id(self, client_id): """ ...
Returns data belonging to an authorization code from memcache or ``None`` if no data was found. See :class:`oauth2.store.AuthCodeStore`. def fetch_by_code(self, code): """ Returns data belonging to an authorization code from memcache or ``None`` if no data was found. S...
Stores the data belonging to an authorization code token in memcache. See :class:`oauth2.store.AuthCodeStore`. def save_code(self, authorization_code): """ Stores the data belonging to an authorization code token in memcache. See :class:`oauth2.store.AuthCodeStore`. """ ...
Stores the access token and additional data in memcache. See :class:`oauth2.store.AccessTokenStore`. def save_token(self, access_token): """ Stores the access token and additional data in memcache. See :class:`oauth2.store.AccessTokenStore`. """ key = self._generate_c...
Deletes a refresh token after use :param refresh_token: The refresh token to delete. def delete_refresh_token(self, refresh_token): """ Deletes a refresh token after use :param refresh_token: The refresh token to delete. """ access_token = self.fetch_by_refresh_token(ref...
Creates a string out of a list of scopes. :param scopes: A list of scopes :param use_quote: Boolean flag indicating whether the string should be quoted :return: Scopes as a string def encode_scopes(scopes, use_quote=False): """ Creates a string out of a list of scopes. :param scopes: A list o...
Formats an error as a response containing a JSON body. def json_error_response(error, response, status_code=400): """ Formats an error as a response containing a JSON body. """ msg = {"error": error.error, "error_description": error.explanation} response.status_code = status_code response.add_...
Formats the response of a successful token request as JSON. Also adds default headers and status code. def json_success_response(data, response): """ Formats the response of a successful token request as JSON. Also adds default headers and status code. """ response.body = json.dumps(data) ...
Compares the scopes read from request with previously issued scopes. :param previous_scopes: A list of scopes. :return: ``True`` def compare(self, previous_scopes): """ Compares the scopes read from request with previously issued scopes. :param previous_scopes: A list of scope...
Parses scope value in given request. Expects the value of the "scope" parameter in request to be a string where each requested scope is separated by a white space:: # One scope requested "profile_read" # Multiple scopes "profile_read profile_write" ...
Reads and validates data in an incoming request as required by the Authorization Request of the Authorization Code Grant and the Implicit Grant. def read_validate_params(self, request): """ Reads and validates data in an incoming request as required by the Authorization Request ...
Controls all steps to authorize a request by a user. :param request: The incoming :class:`oauth2.web.Request` :param response: The :class:`oauth2.web.Response` that will be returned eventually :param environ: The environment variables of this request :param scop...
Generates a new authorization token. A form to authorize the access of the application can be displayed with the help of `oauth2.web.SiteAdapter`. def process(self, request, response, environ): """ Generates a new authorization token. A form to authorize the access of the appl...
Redirects the client in case an error in the auth process occurred. def handle_error(self, error, response): """ Redirects the client in case an error in the auth process occurred. """ query_params = {"error": error.error} query = urlencode(query_params) location = "%s...
Generates a new access token and returns it. Returns the access token and the type of the token as JSON. Calls `oauth2.store.AccessTokenStore` to persist the token. def process(self, request, response, environ): """ Generates a new access token and returns it. Returns the acc...
Takes the incoming request, asks the concrete SiteAdapter to validate it and issues a new access token that is returned to the client on successful validation. def process(self, request, response, environ): """ Takes the incoming request, asks the concrete SiteAdapter to validate ...
Checks if all incoming parameters meet the expected values. def read_validate_params(self, request): """ Checks if all incoming parameters meet the expected values. """ self.client = self.client_authenticator.by_identifier_secret(request) self.password = request.post_param("pas...
Create a new access token. :param request: The incoming :class:`oauth2.web.Request`. :param response: The :class:`oauth2.web.Response` that will be returned to the client. :param environ: A ``dict`` containing data of the environment. :return: :class:`oauth2.we...
Validate the incoming request. :param request: The incoming :class:`oauth2.web.Request`. :return: Returns ``True`` if data is valid. :raises: :class:`oauth2.error.OAuthInvalidError` def read_validate_params(self, request): """ Validate the incoming request. :param re...
Get value from walking key path with start object obj. def value_for_keypath(obj, path): """Get value from walking key path with start object obj. """ val = obj for part in path.split('.'): match = re.match(list_index_re, part) if match is not None: val = _extract(val, match...
Set attribute value new_value at key path of start object obj. def set_value_for_keypath(obj, path, new_value, preserve_child = False): """Set attribute value new_value at key path of start object obj. """ parts = path.split('.') last_part = len(parts) - 1 dst = obj for i, part in enumerate(par...
Create an ImageView for the given image. def view_for_image_named(image_name): """Create an ImageView for the given image.""" image = resource.get_image(image_name) if not image: return None return ImageView(pygame.Rect(0, 0, 0, 0), image)
Install or upgrade setuptools and EasyInstall def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" tarball = download_setuptools() _install(tarball, _build_install_args(argv))
Fill a surface with a linear gradient pattern. color starting color gradient final color rect area to fill; default is surface's rect vertical True=vertical; False=horizontal forward True=forward; False=reverse See http://www.pygame.org/wiki/Gra...
Tightly bound the current text respecting current padding. def shrink_wrap(self): """Tightly bound the current text respecting current padding.""" self.frame.size = (self.text_size[0] + self.padding[0] * 2, self.text_size[1] + self.padding[1] * 2)
Call to have the view layout itself. Subclasses should invoke this after laying out child views and/or updating its own frame. def layout(self): """Call to have the view layout itself. Subclasses should invoke this after laying out child views and/or updating its own frame. ...
Apply theme style attributes to this instance and its children. This also causes a relayout to occur so that any changes in padding or other stylistic attributes may be handled. def stylize(self): """Apply theme style attributes to this instance and its children. This also causes a re...
Do not call directly. def draw(self): """Do not call directly.""" if self.hidden: return False if self.background_color is not None: render.fillrect(self.surface, self.background_color, rect=pygame.Rect((0, 0), self.frame.size)) for...
Return border width for each side top, left, bottom, right. def get_border_widths(self): """Return border width for each side top, left, bottom, right.""" if type(self.border_widths) is int: # uniform size return [self.border_widths] * 4 return self.border_widths
Find the view (self, child, or None) under the point `pt`. def hit(self, pt): """Find the view (self, child, or None) under the point `pt`.""" if self.hidden or not self._enabled: return None if not self.frame.collidepoint(pt): return None local_pt = (pt[0] - ...
TODO: explain depth sorting def bring_to_front(self): """TODO: explain depth sorting""" if self.parent is not None: ch = self.parent.children index = ch.index(self) ch[-1], ch[index] = ch[index], ch[-1]
Make the given theme current. There are two included themes: light_theme, dark_theme. def use_theme(theme): """Make the given theme current. There are two included themes: light_theme, dark_theme. """ global current current = theme import scene if scene.current is not None: sc...
Set a single style value for a view class and state. class_name The name of the class to be styled; do not include the package name; e.g. 'Button'. state The name of the state to be stylized. One of the following: 'normal', 'focused', 'selected', 'disa...
The style dict for a given class and state. This collects the style attributes from parent classes and the class of the given object and gives precedence to values thereof to the children. The state attribute of the view instance is taken as the current state if state is None. ...
The style dict for a view instance. def get_dict(self, obj, state=None, base_name='View'): """The style dict for a view instance. """ return self.get_dict_for_class(class_name=obj.__class__, state=obj.state, base_nam...
Get a single style attribute value for the given class. def get_value(self, class_name, attr, default_value=None, state='normal', base_name='View'): """Get a single style attribute value for the given class. """ styles = self.get_dict_for_class(class_name, state, base_name) ...
Serialize a queryset. def serialize(self, queryset, **options): """ Serialize a queryset. """ self.options = options self.stream = options.pop("stream", six.StringIO()) self.selected_fields = options.pop("fields", None) self.use_natural_keys = options.pop("use_n...
Returns dict of current values for all tracked fields def current(self, fields=None): """Returns dict of current values for all tracked fields""" if fields is None: fields = self.fields return dict((f, self.get_field_value(f)) for f in fields)
Instantiates and returns a model field for FieldHistory.object_id. object_id_class_or_tuple may be either a Django model field class or a tuple of (model_field, kwargs), where kwargs is a dict passed to model_field's constructor. def instantiate_object_id_field(object_id_class_or_tuple=models.TextField): ...
Report if the session key has expired. :param lifetime: A :class:`datetime.timedelta` that specifies the maximum age this :class:`SessionID` should be checked against. :param now: If specified, use this :class:`~datetime.datetime` instance ...
Unserializes from a string. :param string: A string created by :meth:`serialize`. def unserialize(cls, string): """Unserializes from a string. :param string: A string created by :meth:`serialize`. """ id_s, created_s = string.split('_') return cls(int(id_s, 16), ...
Destroys a session completely, by deleting all keys and removing it from the internal store immediately. This allows removing a session for security reasons, e.g. a login stored in a session will cease to exist if the session is destroyed. def destroy(self): """Destroys a session compl...
Generate a new session id for this session. To avoid vulnerabilities through `session fixation attacks <http://en.wikipedia.org/wiki/Session_fixation>`_, this function can be called after an action like a login has taken place. The session will be copied over to a new session id and the...
Removes all expired session from the store. Periodically, this function can be called to remove sessions from the backend store that have expired, as they are not removed automatically unless the backend supports time-to-live and has been configured appropriately (see :class:`~simplekv....
Initialize application and KVSession. This will replace the session management of the application with Flask-KVSession's. :param app: The :class:`~flask.Flask` app to be initialized. def init_app(self, app, session_kvstore=None): """Initialize application and KVSession. This ...
This is a utility function used in the certification modules to transfer the data dicts above to SOAP objects. This avoids repetition and allows us to store all of our variable configuration here rather than in each certification script. def transfer_config_dict(soap_object, data_dict): """ This is...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_requ...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_requ...
This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. ...
Fires off the Fedex shipment validation request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_validation_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_validation_request(self): """ Fires off the Fedex shipment va...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...
Adds a package to the ship request. @type package_item: WSDL object, type of RequestedPackageLineItem WSDL object. @keyword package_item: A RequestedPackageLineItem, created by calling create_wsdl_object_of_type('RequestedPackageLineItem') on this ShipmentRe...
Preps the WSDL data structures for the user. def _prepare_wsdl_objects(self): """ Preps the WSDL data structures for the user. """ self.DeletionControlType = self.client.factory.create('DeletionControlType') self.TrackingId = self.client.factory.create('TrackingId') sel...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY...
This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ This is the data that will be used to create your shipment. Create the data structure and get it ready for th...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRE...
Sets up the WebAuthenticationDetail node. This is required for all requests. def __set_web_authentication_detail(self): """ Sets up the WebAuthenticationDetail node. This is required for all requests. """ # Start of the authentication stuff. web_authentication_c...
Sets up the ClientDetail node, which is required for all shipping related requests. def __set_client_detail(self, *args, **kwargs): """ Sets up the ClientDetail node, which is required for all shipping related requests. """ client_detail = self.client.factory.create('Cl...
Checks kwargs for 'customer_transaction_id' and sets it if present. def __set_transaction_detail(self, *args, **kwargs): """ Checks kwargs for 'customer_transaction_id' and sets it if present. """ customer_transaction_id = kwargs.get('customer_transaction_id', None) if customer...
Pulles the versioning info for the request from the child request. def __set_version_id(self): """ Pulles the versioning info for the request from the child request. """ version_id = self.client.factory.create('VersionId') version_id.ServiceId = self._version_info['service_id']...
This checks the response for general Fedex errors that aren't related to any one WSDL. def __check_response_for_fedex_error(self): """ This checks the response for general Fedex errors that aren't related to any one WSDL. """ if self.response.HighestSeverity == "FAILURE...
Override this in each service module to check for errors that are specific to that module. For example, invalid tracking numbers in a Tracking request. def _check_response_for_request_errors(self): """ Override this in each service module to check for errors that are specific to...
Override this in a service module to check for errors that are specific to that module. For example, changing state/province based on postal code in a Rate Service request. def _check_response_for_request_warnings(self): """ Override this in a service module to check for errors that are...
Sends the assembled request on the child object. @type send_function: function reference @keyword send_function: A function reference (passed without the parenthesis) to a function that will send the request. This allows for overriding the default function in cases such as ...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...
This sets the package identifier information. This may be a tracking number or a few different things as per the Fedex spec. def _prepare_wsdl_objects(self): """ This sets the package identifier information. This may be a tracking number or a few different things as per the Fedex spec. ...
Checks the response to see if there were any errors specific to this WSDL. def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": # pragma: no cover ...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY...
This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. ...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...
Prints all of a shipment's labels, or optionally just one. @type package_num: L{int} @param package_num: 0-based index of the package to print. This is only useful for shipments with more than one package. def print_label(self, package_num=None): """ ...
Pipe the binary directly to the label printer. Works under Linux without requiring PySerial. This is not typically something you should call directly, unless you have special needs. @type base64_data: L{str} @param base64_data: The base64 encoded string for the label to print. ...
Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ # Service defaults for objects that are required. self.MultipleMatchesAction = 'RETURN_ALL' self.Co...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...
Checks the response to see if there were any errors specific to this WSDL. def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": for notifi...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY...
Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.Origin = self.client.factory.create('Address') self.Destination = sel...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...
Converts suds object to dict very quickly. Does not serialize date time or normalize key case. :param obj: suds object :return: dict object def basic_sobject_to_dict(obj): """Converts suds object to dict very quickly. Does not serialize date time or normalize key case. :param obj: suds object ...
Converts a suds object to a dict. Includes advanced features. :param json_serialize: If set, changes date and time types to iso string. :param key_to_lower: If set, changes index key name to lower case. :param obj: suds object :return: dict object def sobject_to_dict(obj, key_to_lower=False, json_seria...
Converts a suds object to a JSON string. :param obj: suds object :param key_to_lower: If set, changes index key name to lower case. :return: json object def sobject_to_json(obj, key_to_lower=False): """ Converts a suds object to a JSON string. :param obj: suds object :param key_to_lower: If...
Create the data structure and get it ready for the WSDL request. def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.RoutingCode = 'FDSD' self.Address = self.client.factory.create('Addre...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTL...