Coder Social home page Coder Social logo

django-acs's Introduction

django-acs

Django ACS Server

NOTE: THIS IS VERY MUCH A WORK IN PROGRESS. EXPECT NOTHING TO WORK UNTIL I GET SOME MORE STUFF DONE.

XML Storage Model

django-acs saves the full history of the ACS sessions. For this purpose it needs a model for XML storage. You need to create this model, and a manager.

The XML Storage Model must have a property called "document" which returns the XML as a string. It must also have a manager with a .create_xml_document() method. This method should accept a single argument named xml, which is the bytes representing the XML, and it must return an instance of the configured XML Storage Model.

For example:

class XMLDocumentManager(models.Manager):
    """
    A custom manager with the required create_xml_document() method
    """
    def create_xml_document(self, xml):
        f = io.BytesIO()
        f.write(xml)
        xmlfile = File(f)
        xmldoc = self.model.objects.create()
        xmldoc.file_document.save("%s.xml" % str(xmldoc.uuid), xmlfile)
        return xmldoc

class XMLDocument(models.Model):
    """
    The XMLDocument model saves XML files to disk and keeps only a reference to the filename in the database.
    """
    objects = XMLDocumentManager()
    xml_document = models.FileField(
        upload_to='xmlarchive/',
        null=True,
        blank=True,
        help_text='The XML Document FileField'
    )

    @cached_property
    def document(self):
        if self.file_document:
            try:
                return self.xml_document.read().decode('utf-8')
            except Exception as E:
                logger.info("got exception while reading XML file %s: %s" % (self.xml_document.path, E))
        # no file or error reading
        return None

You can start out with just a TextField to save the XML, but for any type of large scale operation you should use the filesystem or an object store which can handle millions of files.

Finally configure django-acs to use the class like so:

DJANGO_ACS={
    'xml_storage_model': 'xmlarchive.XMLDocument'
}

Settings

An alphabetical list of all supported settings.

inform_interval (optional)

The inform interval to configure for ACS devices, in seconds.

Default: 3600

inform_limit_per_interval (optional)

The maximum number of Informs (ACS sessions really) we allow a single ACS device to do in the span of a single informinterval. Any more sessions will be rejected with HTTP 420.

Default: 2

xml_storage_model (required)

Sets the model used to store XML documents. See the section XML Storage Model above.

No default.

django-acs's People

Contributors

tykling avatar silasserner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.